(deftemplate persoana
    (slot nume) ;null daca nu are
    (slot sex)
    (slot parinte) ;de preferinta mama
    (slot partener)) ;null daca nu are

(assert (persoana (nume Petru) (sex m) (parinte null) (partener Veta)))
(assert (persoana (nume Veta) (sex f) (parinte null) (partener Petru)))
(assert (persoana (nume Teodor) (sex m) (parinte null) (partener Alberta)))
(assert (persoana (nume Alberta) (sex f) (parinte null) (partener Teodor)))
(assert (persoana (nume Hans) (sex m) (parinte null) (partener Armando)))
(assert (persoana (nume Armando) (sex m) (parinte Veta) (partener Hans)))
(assert (persoana (nume Miguel) (sex m) (parinte Veta) (partener null)))
(assert (persoana (nume George) (sex m) (parinte Veta) (partener Maria)))
(assert (persoana (nume Maria) (sex f) (parinte Alberta) (partener George)))
(assert (persoana (nume Vasilica) (sex f) (parinte Alberta) (partener Mirela)))
(assert (persoana (nume Mirela) (sex f) (parinte null) (partener Vasilica)))
(assert (persoana (nume Nemo) (sex m) (parinte Armando) (partener null)))
(assert (persoana (nume Ionel) (sex m) (parinte Maria) (partener null)))
(assert (persoana (nume Oana) (sex f) (parinte null) (partener null)))
(assert (persoana (nume Vanessa) (sex f) (parinte Mirela) (partener null)))

(defrule mama1
    (persoana (nume ?nc) (parinte ?np))
    (persoana (nume ?np) (sex f))
    =>
    (printout t "Persoana " ?nc " are mama " ?np crlf)
)

(defrule mama2
	(persoana (nume ?nc) (parinte ?np))
    (persoana (nume ?np) (partener ?npp))
    (persoana (nume ?npp) (sex f))
    =>
    (printout t "Persoana " ?nc " are mama " ?npp crlf)        
)

(defrule tata
    (persoana (nume ?nc) (parinte ?np))
    (persoana (nume ?np) (sex m))
    =>
    (printout t "Persoana " ?nc " are tata " ?np crlf)
    )

(defrule sotie
    (persoana (nume ?nc) (partener ?p))
    (persoana (nume ?nc) (sex m))
    =>
     (printout t "Persoana " ?nc " are sotia " ?p crlf)
    )

(defrule sot
    (persoana (nume ?nc) (partener ?p))
    (persoana (nume ?nc) (sex f))
    =>
     (printout t "Persoana " ?nc " are sotul " ?p crlf)
    )

(run)